package com.maddox.mworld.dao;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.maddox.mworld.entity.Picture;


@Database(entities = {Picture.class}, version = 1)
public abstract class AppDatabase extends RoomDatabase {

    private static final String DB_NAME = "myworld.db";


    private static AppDatabase instance;

    public AppDatabase getInstance(Context context) {
        if (instance == null) {
            synchronized (this) {
                if (instance == null) {
                    instance = Room.databaseBuilder(context, AppDatabase.class, DB_NAME)
                            .allowMainThreadQueries()
                            .build();
                }
            }
        }
        return instance;
    }


    public abstract PictureDao pictureDao();


}
